/**
 * 
 */
package com.evon.yardmanagement.service;

import java.util.List;

import com.evon.yardmanagement.dao.KeyBinDAO;
import com.evon.yardmanagement.model.KeyBin;
import com.evon.yardmanagement.model.Vendor;
import com.evon.yardmanagement.model.Yard;

/**
 * @author Sandeep
 * 
 */
public class KeyBinManagementService implements IKeyBinManagementService {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.evon.yardmanagement.service.IKeyBinManagementService#addKeyBin(com
	 * .evon.yardmanagement.model.IKeyBin)
	 */

	KeyBinDAO keyBinDao = new KeyBinDAO();

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.evon.yardmanagement.service.IKeyBinManagementService#deactivateKeyBin
	 * (com.evon.yardmanagement.model.IKeyBin)
	 */
	public boolean deactivateKeyBin(KeyBin keybin) {
		// TODO Auto-generated method stub
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.evon.yardmanagement.service.IKeyBinManagementService#getAllKeyBins()
	 */
	public List<KeyBin> getAllKeyBins() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.evon.yardmanagement.service.IKeyBinManagementService#getkeyBinDetails
	 * (com.evon.yardmanagement.model.ICompany)
	 */
	public List<KeyBin> getkeyBinDetails(Vendor company) {
		// TODO Auto-generated method stub
		return null;
	}

	public int addKeyBin(KeyBin keyBin) {
		keyBinDao.saveOrUpdate(keyBin);
		return keyBin.getId();
	}

	public List<KeyBin> getKeyBinByYardId(Integer id) {
		// TODO Auto-generated method stub
		Yard yard = new Yard();
		yard.setId(id);
		return keyBinDao.findByProperty("yard", yard);
	}

	public List<KeyBin> getKeyBinByKeyBinId(Integer id) {
		// TODO Auto-generated method stub
		return keyBinDao.findByProperty("id", id);
	}

	public void importKeyBins(List<KeyBin> data) {
		if (data != null && !data.isEmpty()) {
			for (KeyBin keyBin : data) {
				keyBinDao.saveOrUpdate(keyBin);
			}
		}

	}

}
